package com.second.app.thread.stream;

import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
/**
 * @author gyz
 * @date 2021/1/27 9:28
 */
public class Main {
    public static void main(String[] args) {
        try {
            PipedInputStream pipedInputStream = new PipedInputStream();
            PipedOutputStream pipedOutputStream = new PipedOutputStream();

            pipedInputStream.connect(pipedOutputStream);
            //写线程
            WriteData writeData = new WriteData();
            ThreadWrite threadWrite = new ThreadWrite(writeData, pipedOutputStream);
            threadWrite.start();
            Thread.sleep(5000);
            //读线程
            ReadData readData = new ReadData();
            ThreadRead threadRead = new ThreadRead(readData, pipedInputStream);
            threadRead.start();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
